package com.zhaokuner.springcloudconfigserver.test;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.zookeeper.CreateMode;

/**
 * <p>
 * Description:测试
 * <p>
 * Copyright: 2018-现在 北京掌通未来科技有限公司
 * <p>
 *
 * @author 赵希坤 zhaoxikun
 * @date 2020/7/24 15:19
 */
public class TT {
    public static CuratorFramework init() {
        RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        CuratorFramework client = CuratorFrameworkFactory.builder()
                .connectString("zhaokuner.com:2181")
                .retryPolicy(retryPolicy)
                .build();
        client.start();
        return client;
    }

    public static void main(String[] args) throws Exception {
        CuratorFramework client = init();
        for (int i = 0; i < 30; i++) {
            client.create().orSetData().withMode(CreateMode.EPHEMERAL).forPath("/a", ("bbbb" + i).getBytes());
            System.out.println(i);
            Thread.sleep(1000);
        }

        Thread.sleep(2000000000);
//        Object o = client.getChildren().forPath("/");
//        System.out.println(o);
    }
}
